var features = {
    1: "CompanySearch",
    2: "ScreeningToolBusinessOverview",
    3: "ScreeningToolFinancialMetrics",
    4: "ScreeningToolRatings",
    5: "ScreeningToolEnvironment",
    6: "ScreeningToolSocial",
    7: "ScreeningToolGovernance",
    8: "ScreeningToolESGEvents",
    9: "ProductInvolvement",
    10: "GlobalCompactNonCompliant",
    11: "GlobalCompactWatchlist",
    12: "GlobalCompactWatchlistAndNonCompliant",
    13: "EsgRatingsOnlineReport",
    14: "Controversies",
    15: "Governance",
    16: "ScreeningToolControversies",
    17: "AlertControversies",
    18: "RiskRatingsResearch"
}

var dbGroup = db.getSiblingDB("ClientPlatform").ConnectionStrings.findOne({}).DatabaseGroup
var collections = [ db.getSiblingDB("ClientUniverses_A").FeatureUniverse, db.getSiblingDB("ClientUniverses_B").FeatureUniverse ]
collections.forEach(function(collection){
    
    var bulk = collection.initializeUnorderedBulkOp();
    var myDocuments = collection.find({Feature: { $type: 16 }}); 
    var ops = 0;     
    var startDate = new Date();
    myDocuments.forEach( 
        function(item){
            item.Feature = features[item.Feature];
            bulk.find({ _id: item._id }).replaceOne(item);
            
            if ((++ops %1000) === 0){
                bulk.execute();
                bulk = collection.initializeUnorderedBulkOp();
           }
        }
    )
                
    bulk.execute();   
    var endDate = new Date();
    print("\t\t\t" + collection + "\n\nStartDate: " + startDate + "\nEndDate: " + endDate + "\n\n")
})